#!/bin/bash

## Création des dossiers

echo Create folder for backup process

mkdir /usr/local/backup/
cd /usr/local/backup/
mkdir database application
cd application 
mkdir plugin_nagios centreon_web
cd ~

## Extraction des bases de données

echo Extract databases

mysqldump -u root -pGaTFsttaC2K6 centreon>/usr/local/backup/database/centreon.sql
mysqldump -u root -pGaTFsttaC2K6 centstatus>/usr/local/backup/database/centstatus.sql
mysqldump -u root -pGaTFsttaC2K6 centstorage>/usr/local/backup/database/centstorage.sql

## Copie des applications

## Plugins Nagios

cp -R /usr/local/nagios/libexec/ /usr/local/backup/application/plugin_nagios/

## Centreon Web

cp -R /usr/local/centreon/ /usr/local/backup/application/centreon_web/


## Création de l'archive

cd /usr/local/
tar cfvz backup-nagcent.tar.gz backup/
mv backup-nagcent.tar.gz /root/

## Suppression des dossiers temporaires

rm -R /usr/local/backup

